import java.io.*;
import java.util.*;


public class SequenceFrompdb{

	public static Set getFileNames()
	{
		Set<String> fileNameSet = new TreeSet<String>();
		try{
			File locationFile = new File("location");
			
			Scanner locInput = new Scanner(locationFile);
			while(locInput.hasNext())
			{
				String fileName = locInput.nextLine();
				String[] fileNames = fileName.split("\\s");
				int length = fileNames[0].length();
				
				String fileFinal = fileNames[0].substring(length-8,length-5);
				fileNameSet.add(fileFinal);
			}

			for(String a1: fileNameSet)
			{
		
				//System.out.println(a1);
			
			}


		}
		catch(FileNotFoundException e)
	{
		e.printStackTrace();
	}
	return fileNameSet;
	

	}
	public static void main(String[] args) {
		Set<String> files = new TreeSet<String>();
		files = getFileNames();
		//System.out.println(args[0] + " " + args[1]);
		ArrayList<String> alp = new ArrayList<String>();
		try
		{
		PrintWriter writer = new PrintWriter("log.txt");

		for(String a1: files){
			try{
		
				File file1 = new File(a1);
		
		
				Scanner read = new Scanner(file1);
		
				
		
				
		
				while(read.hasNext())
					{
		 				String test = read.nextLine();
		 				String[] test1 = test.split("\\s+");
		 				//System.out.println(test);
		 	
		 				if(test1[0].equals(args[0]) && test1[1].equals(args[1]))
		 						{
		 							if(test1.length > 5)
		 							alp.add(test1[6]);

		 							else
		 								//writer.println("Problem with: "+ test);
		 								System.out.println("Problem with: "+ test);

		 						}

		 	
					}

	

	

						for(String a: alp)
						{
		
							System.out.print(a+"");
						}

		
		
	}
	catch(FileNotFoundException e)
	{
		e.printStackTrace();
	}

	}
	writer.close();
}
catch(FileNotFoundException e1)
{
	e1.printStackTrace();
}
}
}
